using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS.Plugin.Advance;

public class FormAdvance : Form
{
	private FormIonSource formPlasma = null;

	private FormPower formPower = null;

	private FormQuad formQuad = null;

	private FormVacuum formVacuum = null;

	private FormIgnite formIgnite = null;

	private FormVersion formVersion = null;

	private FormSemiConductor formSemiConductor = null;

	private FormUPS formUPS = null;

	private FormInstrumentConfig formInstrumentConfig = null;

	private FormPlat formPlat = null;

	private FormSettings formSettings = null;

	private FormVideo formVideo = null;

	private IContainer components = null;

	private TabControl tabAdvance;

	private TabPage pagePower;

	private TabPage pagePlasma;

	private TabPage pageQP;

	private TabPage pageVacuum;

	private ToolTip toolTipTurbo;

	private TabPage pagePlat;

	private TabPage pageIgniteConfig;

	private TabPage pageVersion;

	private TabPage pageSemiConductor;

	private TabPage pageUPS;

	private TabPage pageSettings;

	private TabPage pageVideo;

	public FormAdvance()
	{
		InitializeComponent();
	}

	private void FormAdvance_Load(object sender, EventArgs e)
	{
		ApplyResources();
		base.WindowState = FormWindowState.Maximized;
		UserManager.UserChanged += UserManager_UserChanged;
		PermissionManagement();
		InitPower();
		InitQP();
		InitICP();
		InitVacuum();
		InitPlat();
		InitIgniteConfig();
		InitVersion();
		InitSemiConductor();
		InitUPS();
		InitSettins();
		InitVideo();
	}

	private void UserManager_UserChanged(object sender, EventArgs e)
	{
		PermissionManagement();
	}

	private void FormAdvance_FormClosing(object sender, FormClosingEventArgs e)
	{
		if (formPlasma.IsRecord)
		{
			formPlasma.IsRecord = false;
			if (MessageBox.Show(Lang.Txt("AddFormAdvance.CurveRecordWarn"), Lang.Txt("AddFormAdvance.Warn"), MessageBoxButtons.YesNo) != DialogResult.Yes)
			{
				e.Cancel = true;
				return;
			}
			formPlasma.IsRecord = false;
		}
		UserManager.UserChanged -= UserManager_UserChanged;
		TermPower();
		TermICP();
		TermVacuum();
		TermQP();
		TermPlat();
		TermIgnite();
		TermVersion();
		TermSemiConductor();
		TermUPS();
		TermSettings();
		TermVideo();
	}

	private void PermissionManagement()
	{
		if (UserManager.CurrentUser.authority <= 1)
		{
			pagePlat.Parent = null;
			pageIgniteConfig.Parent = null;
			pageVersion.Parent = null;
			pageSemiConductor.Parent = null;
			pageUPS.Parent = null;
			pageSettings.Parent = null;
		}
		else
		{
			pagePlat.Parent = tabAdvance;
			pageIgniteConfig.Parent = tabAdvance;
			pageVersion.Parent = tabAdvance;
			pageSemiConductor.Parent = tabAdvance;
			pageUPS.Parent = tabAdvance;
			pageSettings.Parent = tabAdvance;
		}
	}

	private void InitPower()
	{
		if (formPower == null)
		{
			formPower = new FormPower();
			formPower.TopLevel = false;
			formPower.Parent = pagePower;
			formPower.FormBorderStyle = FormBorderStyle.None;
			formPower.Dock = DockStyle.Fill;
			formPower.Show();
		}
	}

	private void TermPower()
	{
		if (formPower != null)
		{
			formPower.Close();
		}
	}

	private void InitIgniteConfig()
	{
		if (formIgnite == null)
		{
			formIgnite = new FormIgnite();
			formIgnite.TopLevel = false;
			formIgnite.Parent = pageIgniteConfig;
			formIgnite.FormBorderStyle = FormBorderStyle.None;
			formIgnite.Dock = DockStyle.Fill;
			formIgnite.Show();
		}
	}

	private void TermIgnite()
	{
		if (formIgnite != null)
		{
			formIgnite.Close();
		}
	}

	private void InitQP()
	{
		if (formQuad == null)
		{
			formQuad = new FormQuad();
			formQuad.TopLevel = false;
			formQuad.Parent = pageQP;
			formQuad.FormBorderStyle = FormBorderStyle.None;
			formQuad.Dock = DockStyle.Fill;
			formQuad.Show();
		}
	}

	private void TermQP()
	{
		if (formQuad != null)
		{
			formQuad.Close();
		}
	}

	private void InitVacuum()
	{
		if (formVacuum == null)
		{
			formVacuum = new FormVacuum();
			formVacuum.TopLevel = false;
			formVacuum.Parent = pageVacuum;
			formVacuum.FormBorderStyle = FormBorderStyle.None;
			formVacuum.Dock = DockStyle.Fill;
			formVacuum.Show();
		}
	}

	private void TermVacuum()
	{
		if (formVacuum != null)
		{
			formVacuum.Close();
		}
	}

	private void InitICP()
	{
		if (formPlasma == null)
		{
			formPlasma = new FormIonSource();
			formPlasma.TopLevel = false;
			formPlasma.Parent = pagePlasma;
			formPlasma.FormBorderStyle = FormBorderStyle.None;
			formPlasma.Dock = DockStyle.Fill;
			formPlasma.Show();
		}
	}

	private void TermICP()
	{
		if (formPlasma != null)
		{
			formPlasma.Close();
		}
	}

	private void InitPlat()
	{
		if (formPlat == null)
		{
			formPlat = new FormPlat();
			formPlat.TopLevel = false;
			formPlat.Parent = pagePlat;
			formPlat.FormBorderStyle = FormBorderStyle.None;
			formPlat.Dock = DockStyle.Fill;
			formPlat.Show();
		}
	}

	private void TermPlat()
	{
		if (formPlat != null)
		{
			formPlat.Close();
		}
	}

	private void InitVersion()
	{
		if (formVersion == null)
		{
			formVersion = new FormVersion();
			formVersion.TopLevel = false;
			formVersion.Parent = pageVersion;
			formVersion.FormBorderStyle = FormBorderStyle.None;
			formVersion.Dock = DockStyle.Fill;
			formVersion.Show();
		}
	}

	private void TermVersion()
	{
		if (formVersion != null)
		{
			formVersion.Close();
		}
	}

	private void InitSemiConductor()
	{
		if (formSemiConductor == null)
		{
			formSemiConductor = new FormSemiConductor();
			formSemiConductor.TopLevel = false;
			formSemiConductor.Parent = pageSemiConductor;
			formSemiConductor.FormBorderStyle = FormBorderStyle.None;
			formSemiConductor.Dock = DockStyle.Fill;
			formSemiConductor.Show();
		}
	}

	private void InitUPS()
	{
		if (formUPS == null)
		{
			formUPS = new FormUPS();
			formUPS.TopLevel = false;
			formUPS.Parent = pageUPS;
			formUPS.FormBorderStyle = FormBorderStyle.None;
			formUPS.Dock = DockStyle.Fill;
			formUPS.Show();
		}
	}

	private void InitSettins()
	{
		if (formSettings == null)
		{
			formSettings = new FormSettings();
			formSettings.TopLevel = false;
			formSettings.Parent = pageSettings;
			formSettings.FormBorderStyle = FormBorderStyle.None;
			formSettings.Dock = DockStyle.Fill;
			formSettings.Show();
		}
	}

	private void InitVideo()
	{
		if (formVideo == null)
		{
			formVideo = new FormVideo();
			formVideo.TopLevel = false;
			formVideo.Parent = pageVideo;
			formVideo.FormBorderStyle = FormBorderStyle.None;
			formVideo.Dock = DockStyle.Fill;
			formVideo.Show();
		}
	}

	private void TermUPS()
	{
		if (formUPS != null)
		{
			formUPS.Close();
		}
	}

	private void TermSettings()
	{
		if (formSettings != null)
		{
			formSettings.Close();
		}
	}

	private void TermVideo()
	{
		if (formVideo != null)
		{
			formVideo.Close();
		}
	}

	private void TermSemiConductor()
	{
		if (formSemiConductor != null)
		{
			formSemiConductor.Close();
		}
	}

	private void InitInstrumentConfig()
	{
		if (formInstrumentConfig == null)
		{
			formInstrumentConfig = new FormInstrumentConfig();
			formInstrumentConfig.TopLevel = false;
			formInstrumentConfig.Parent = pageSettings;
			formInstrumentConfig.FormBorderStyle = FormBorderStyle.None;
			formInstrumentConfig.Dock = DockStyle.Fill;
			formInstrumentConfig.Show();
		}
	}

	private void TermInstrumentConfig()
	{
		if (formInstrumentConfig != null)
		{
			formInstrumentConfig.Close();
		}
	}

	private void ApplyResources()
	{
		pagePower.Text = Lang.Txt("FormAdvance.PowerManagement.Text");
		pagePlasma.Text = Lang.Txt("FormAdvance.Solid_stateLighting.Text ");
		pageIgniteConfig.Text = Lang.Txt("FormAdvance.IgnitConfig.Text");
		pageQP.Text = Lang.Txt("FormAdvance.Quadrupole.Text ");
		pageVacuum.Text = Lang.Txt("FormAdvance.VaccumSystem.Text ");
		pagePlat.Text = Lang.Txt("FormAdvance.PlatManager.Text ");
		Text = Lang.Txt("FormAdvance.Title.Text");
		pageSemiConductor.Text = Lang.Txt("ADD.SemiConductor.Text");
		pageVersion.Text = Lang.Txt("ADD.Version.Text");
		pageSettings.Text = Lang.Txt("ADD.Setting.Text");
		pageUPS.Text = Lang.Txt("ADD.UPS.Text");
		pageVideo.Text = Lang.Txt("FormMonitor.Text");
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.components = new System.ComponentModel.Container();
		this.tabAdvance = new System.Windows.Forms.TabControl();
		this.pagePower = new System.Windows.Forms.TabPage();
		this.pagePlasma = new System.Windows.Forms.TabPage();
		this.pageQP = new System.Windows.Forms.TabPage();
		this.pageVacuum = new System.Windows.Forms.TabPage();
		this.pagePlat = new System.Windows.Forms.TabPage();
		this.pageIgniteConfig = new System.Windows.Forms.TabPage();
		this.pageSemiConductor = new System.Windows.Forms.TabPage();
		this.pageVersion = new System.Windows.Forms.TabPage();
		this.pageUPS = new System.Windows.Forms.TabPage();
		this.pageSettings = new System.Windows.Forms.TabPage();
		this.toolTipTurbo = new System.Windows.Forms.ToolTip(this.components);
		this.pageVideo = new System.Windows.Forms.TabPage();
		this.tabAdvance.SuspendLayout();
		base.SuspendLayout();
		this.tabAdvance.Controls.Add(this.pagePower);
		this.tabAdvance.Controls.Add(this.pagePlasma);
		this.tabAdvance.Controls.Add(this.pageQP);
		this.tabAdvance.Controls.Add(this.pageVacuum);
		this.tabAdvance.Controls.Add(this.pagePlat);
		this.tabAdvance.Controls.Add(this.pageIgniteConfig);
		this.tabAdvance.Controls.Add(this.pageSemiConductor);
		this.tabAdvance.Controls.Add(this.pageVersion);
		this.tabAdvance.Controls.Add(this.pageUPS);
		this.tabAdvance.Controls.Add(this.pageSettings);
		this.tabAdvance.Controls.Add(this.pageVideo);
		this.tabAdvance.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tabAdvance.Location = new System.Drawing.Point(0, 0);
		this.tabAdvance.Margin = new System.Windows.Forms.Padding(4);
		this.tabAdvance.Name = "tabAdvance";
		this.tabAdvance.SelectedIndex = 0;
		this.tabAdvance.Size = new System.Drawing.Size(1085, 866);
		this.tabAdvance.TabIndex = 1;
		this.pagePower.BackColor = System.Drawing.SystemColors.Control;
		this.pagePower.Location = new System.Drawing.Point(4, 25);
		this.pagePower.Margin = new System.Windows.Forms.Padding(4);
		this.pagePower.Name = "pagePower";
		this.pagePower.Padding = new System.Windows.Forms.Padding(4);
		this.pagePower.Size = new System.Drawing.Size(1077, 837);
		this.pagePower.TabIndex = 0;
		this.pagePower.Text = "电源设置";
		this.pagePlasma.AutoScroll = true;
		this.pagePlasma.BackColor = System.Drawing.SystemColors.Control;
		this.pagePlasma.Location = new System.Drawing.Point(4, 25);
		this.pagePlasma.Margin = new System.Windows.Forms.Padding(4);
		this.pagePlasma.Name = "pagePlasma";
		this.pagePlasma.Padding = new System.Windows.Forms.Padding(4);
		this.pagePlasma.Size = new System.Drawing.Size(1077, 837);
		this.pagePlasma.TabIndex = 2;
		this.pagePlasma.Text = "固态光源";
		this.pageQP.BackColor = System.Drawing.SystemColors.Control;
		this.pageQP.Location = new System.Drawing.Point(4, 25);
		this.pageQP.Margin = new System.Windows.Forms.Padding(4);
		this.pageQP.Name = "pageQP";
		this.pageQP.Padding = new System.Windows.Forms.Padding(4);
		this.pageQP.Size = new System.Drawing.Size(1077, 837);
		this.pageQP.TabIndex = 3;
		this.pageQP.Text = "四极杆";
		this.pageVacuum.BackColor = System.Drawing.SystemColors.Control;
		this.pageVacuum.Location = new System.Drawing.Point(4, 25);
		this.pageVacuum.Margin = new System.Windows.Forms.Padding(4);
		this.pageVacuum.Name = "pageVacuum";
		this.pageVacuum.Padding = new System.Windows.Forms.Padding(4);
		this.pageVacuum.Size = new System.Drawing.Size(1077, 837);
		this.pageVacuum.TabIndex = 4;
		this.pageVacuum.Text = "真空系统";
		this.pagePlat.Location = new System.Drawing.Point(4, 25);
		this.pagePlat.Margin = new System.Windows.Forms.Padding(4);
		this.pagePlat.Name = "pagePlat";
		this.pagePlat.Size = new System.Drawing.Size(1077, 837);
		this.pagePlat.TabIndex = 5;
		this.pagePlat.Text = "三维平台";
		this.pagePlat.UseVisualStyleBackColor = true;
		this.pageIgniteConfig.Location = new System.Drawing.Point(4, 25);
		this.pageIgniteConfig.Margin = new System.Windows.Forms.Padding(4);
		this.pageIgniteConfig.Name = "pageIgniteConfig";
		this.pageIgniteConfig.Padding = new System.Windows.Forms.Padding(4);
		this.pageIgniteConfig.Size = new System.Drawing.Size(1077, 837);
		this.pageIgniteConfig.TabIndex = 6;
		this.pageIgniteConfig.Text = "点火参数";
		this.pageIgniteConfig.UseVisualStyleBackColor = true;
		this.pageSemiConductor.Location = new System.Drawing.Point(4, 25);
		this.pageSemiConductor.Margin = new System.Windows.Forms.Padding(4);
		this.pageSemiConductor.Name = "pageSemiConductor";
		this.pageSemiConductor.Padding = new System.Windows.Forms.Padding(4);
		this.pageSemiConductor.Size = new System.Drawing.Size(1077, 837);
		this.pageSemiConductor.TabIndex = 8;
		this.pageSemiConductor.Text = "半导体制冷";
		this.pageSemiConductor.UseVisualStyleBackColor = true;
		this.pageVersion.Location = new System.Drawing.Point(4, 25);
		this.pageVersion.Margin = new System.Windows.Forms.Padding(4);
		this.pageVersion.Name = "pageVersion";
		this.pageVersion.Padding = new System.Windows.Forms.Padding(4);
		this.pageVersion.Size = new System.Drawing.Size(1077, 837);
		this.pageVersion.TabIndex = 7;
		this.pageVersion.Text = "硬件版本说明";
		this.pageVersion.UseVisualStyleBackColor = true;
		this.pageUPS.Location = new System.Drawing.Point(4, 25);
		this.pageUPS.Name = "pageUPS";
		this.pageUPS.Padding = new System.Windows.Forms.Padding(3);
		this.pageUPS.Size = new System.Drawing.Size(1077, 837);
		this.pageUPS.TabIndex = 10;
		this.pageUPS.Text = "UPS电源设置";
		this.pageUPS.UseVisualStyleBackColor = true;
		this.pageSettings.Location = new System.Drawing.Point(4, 25);
		this.pageSettings.Name = "pageSettings";
		this.pageSettings.Padding = new System.Windows.Forms.Padding(3);
		this.pageSettings.Size = new System.Drawing.Size(1077, 837);
		this.pageSettings.TabIndex = 11;
		this.pageSettings.Text = "硬件配置";
		this.pageSettings.UseVisualStyleBackColor = true;
		this.pageVideo.Location = new System.Drawing.Point(4, 25);
		this.pageVideo.Name = "pageVideo";
		this.pageVideo.Size = new System.Drawing.Size(1077, 837);
		this.pageVideo.TabIndex = 12;
		this.pageVideo.Text = "等离子体监控";
		this.pageVideo.UseVisualStyleBackColor = true;
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(1085, 866);
		base.Controls.Add(this.tabAdvance);
		base.Margin = new System.Windows.Forms.Padding(4);
		base.Name = "FormAdvance";
		base.ShowIcon = false;
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
		this.Text = "高级设置";
		base.WindowState = System.Windows.Forms.FormWindowState.Maximized;
		base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(FormAdvance_FormClosing);
		base.Load += new System.EventHandler(FormAdvance_Load);
		this.tabAdvance.ResumeLayout(false);
		base.ResumeLayout(false);
	}
}
